# test-script for QUTest unit testing harness
# see https://www.state-machine.com/qtools/qutest.html/qutest.html

# preamble...
def on_reset():
    expect_pause()
    continue_test()
    expect_run()
    glb_filter(GRP_ALL)
    loc_filter(IDS_ALL)
    current_obj(OBJ_SM, "Philo_inst[2]")
    current_obj(OBJ_TE, "Philo_inst[2].timeEvt")

# tests...
test("Philo-thinking TIMEOUT")
dispatch("TIMEOUT_SIG")
expect("@timestamp MP-Get   Obj=EvtPool1,*")
expect("@timestamp QF-New   Sig=TIMEOUT_SIG,*")
expect("@timestamp Disp===> Obj=Philo_inst[2],Sig=TIMEOUT_SIG,State=Philo_thinking")
expect("@timestamp TE0-Dis  Obj=Philo_inst[2].timeEvt,AO=Table_dummy,Tim=*,Int=0")
expect("===RTC===> St-Exit  Obj=Philo_inst[2],State=Philo_thinking")
expect("@timestamp MP-Get   Obj=EvtPool1,*")
expect("@timestamp QF-New   Sig=HUNGRY_SIG,*")
expect("@timestamp AO-LIFO  Obj=Table_dummy,Evt<Sig=HUNGRY_SIG,*")
expect("@timestamp QUTEST_ON_POST HUNGRY_SIG,Obj=Table_dummy 2")
expect("@timestamp QF-gc    Evt<Sig=HUNGRY_SIG,*")
expect("@timestamp MP-Put   Obj=EvtPool1,*")
expect("===RTC===> St-Entry Obj=Philo_inst[2],State=Philo_hungry")
expect("@timestamp ===>Tran Obj=Philo_inst[2],Sig=TIMEOUT_SIG,State=Philo_thinking->Philo_hungry")
expect("@timestamp QF-gc    Evt<Sig=TIMEOUT_SIG,*")
expect("@timestamp MP-Put   Obj=EvtPool1,*")
expect("@timestamp Trg-Done QS_RX_EVENT")

test("Philo-hungry EAT", NORESET)
dispatch("EAT_SIG", pack("<B", 2))
expect("@timestamp MP-Get   Obj=EvtPool1,*")
expect("@timestamp QF-New   Sig=EAT_SIG,*")
expect("@timestamp Disp===> Obj=Philo_inst[2],Sig=EAT_SIG,State=Philo_hungry")
expect("@timestamp BSP_CALL BSP_random *")
expect("@timestamp TE0-Arm  Obj=Philo_inst[2].timeEvt,AO=Table_dummy,Tim=*,Int=0")
expect("===RTC===> St-Entry Obj=Philo_inst[2],State=Philo_eating")
expect("@timestamp ===>Tran Obj=Philo_inst[2],Sig=EAT_SIG,State=Philo_hungry->Philo_eating")
expect("@timestamp QF-gc    Evt<Sig=EAT_SIG,*")
expect("@timestamp MP-Put   Obj=EvtPool1,*")
expect("@timestamp Trg-Done QS_RX_EVENT")

test("Philo-eating TIMEOUT", NORESET)
dispatch("TIMEOUT_SIG")
expect("@timestamp MP-Get   Obj=EvtPool1,*")
expect("@timestamp QF-New   Sig=TIMEOUT_SIG,*")
expect("@timestamp Disp===> Obj=Philo_inst[2],Sig=TIMEOUT_SIG,State=Philo_eating")
expect("@timestamp TE0-Dis  Obj=Philo_inst[2].timeEvt,AO=Table_dummy,Tim=*,Int=0")
expect("@timestamp MP-Get   Obj=EvtPool1,*")
expect("@timestamp QF-New   Sig=DONE_SIG,*")
expect("@timestamp AO-LIFO  Obj=Table_dummy,Evt<Sig=DONE_SIG,*")
expect("@timestamp QUTEST_ON_POST DONE_SIG,Obj=Table_dummy 2")
expect("@timestamp QF-gc    Evt<Sig=DONE_SIG,*")
expect("@timestamp MP-Put   Obj=EvtPool1,*")
expect("===RTC===> St-Exit  Obj=Philo_inst[2],State=Philo_eating")
expect("@timestamp BSP_CALL BSP_random *")
expect("@timestamp TE0-Arm  Obj=Philo_inst[2].timeEvt,AO=Table_dummy,Tim=*,Int=0")
expect("===RTC===> St-Entry Obj=Philo_inst[2],State=Philo_thinking")
expect("@timestamp ===>Tran Obj=Philo_inst[2],Sig=TIMEOUT_SIG,State=Philo_eating->Philo_thinking")
expect("@timestamp QF-gc    Evt<Sig=TIMEOUT_SIG,*")
expect("@timestamp MP-Put   Obj=EvtPool1,*")
expect("@timestamp Trg-Done QS_RX_EVENT")

test("Philo-thinking TIMEOUT(2)", NORESET)
dispatch("TIMEOUT_SIG")
expect("@timestamp MP-Get   Obj=EvtPool1,*")
expect("@timestamp QF-New   Sig=TIMEOUT_SIG,*")
expect("@timestamp Disp===> Obj=Philo_inst[2],Sig=TIMEOUT_SIG,State=Philo_thinking")
expect("@timestamp TE0-Dis  Obj=Philo_inst[2].timeEvt,AO=Table_dummy,Tim=*,Int=0")
expect("===RTC===> St-Exit  Obj=Philo_inst[2],State=Philo_thinking")
expect("@timestamp MP-Get   Obj=EvtPool1,*")
expect("@timestamp QF-New   Sig=HUNGRY_SIG,*")
expect("@timestamp AO-LIFO  Obj=Table_dummy,Evt<Sig=HUNGRY_SIG,*")
expect("@timestamp QUTEST_ON_POST HUNGRY_SIG,Obj=Table_dummy 2")
expect("@timestamp QF-gc    Evt<Sig=HUNGRY_SIG,*")
expect("@timestamp MP-Put   Obj=EvtPool1,*")
expect("===RTC===> St-Entry Obj=Philo_inst[2],State=Philo_hungry")
expect("@timestamp ===>Tran Obj=Philo_inst[2],Sig=TIMEOUT_SIG,State=Philo_thinking->Philo_hungry")
expect("@timestamp QF-gc    Evt<Sig=TIMEOUT_SIG,*")
expect("@timestamp MP-Put   Obj=EvtPool1,*")
expect("@timestamp Trg-Done QS_RX_EVENT")
